# class Washer():
#     def __init__(self,width,height):
#         self.width = width
#         self.height = height
#
#     def print_info(self):
#         print(f'洗衣机的宽度是{self.width}')
#         print(f'洗衣机的高度是{self.height}')
#
#     def __str__(self):
#         # return '这是海尔洗衣机的说明书\n'
#
#     def __del__(self):
#         print(f'{self}对象已经被删除')
#
# haier1 = Washer(10,20)
# haier1.print_info()
#
# class WashingMachine:
#     def __init__(self, brand, model):
#         """
#         初始化洗衣机对象
#         :param brand: 洗衣机的品牌
#         :param model: 洗衣机的型号
#         """
#         self.brand = brand
#         self.model = model
#         self.status = "空闲"  # 洗衣机的初始状态
#
#     def start(self):
#         """
#         开始洗衣过程
#         """
#         if self.status == "空闲":
#             self.status = "运行中"
#             print(f"{self.brand} {self.model} 洗衣机开始运行。")
#         else:
#             print(f"错误：洗衣机当前状态为{self.status}，无法开始。")
#
#     def pause(self):
#         """
#         暂停洗衣过程
#         """
#         if self.status == "运行中":
#             self.status = "暂停"
#             print(f"{self.brand} {self.model} 洗衣机已暂停。")
#         else:
#             print(f"错误：洗衣机当前状态为{self.status}，无法暂停。")
#
#     def stop(self):
#         """
#         停止洗衣过程
#         """
#         if self.status in ["运行中", "暂停"]:
#             self.status = "空闲"
#             print(f"{self.brand} {self.model} 洗衣机已停止。")
#         else:
#             print(f"错误：洗衣机当前状态为{self.status}，无需停止。")
#
#     def get_status(self):
#         """
#         获取洗衣机的当前状态
#         """
#         return self.status
#
#     # 使用示例
#
#
# wm = WashingMachine("海尔", "XQG100-B14876LU1")
# wm.start()
# print(f"洗衣机当前状态：{wm.get_status()}")
# wm.pause()
# print(f"洗衣机当前状态：{wm.get_status()}")
# wm.stop()
# print(f"洗衣机当前状态：{wm.get_status()}")
# class SweetPotato:
#     def __init__(self):
#         self.time = 0
#         self.state = '生的'
#         self.condition = []
#
#     def __str__(self):
#         return f"这个地瓜烤了:{self.time}分钟，状态是:{self.state},加了:{self.condition}调料"
#
#     def cook(self, time):
#         self.time += time
#         if self.time > 60:
#             self.state = "哥么，熟透了"
#         elif 30 <= self.time <= 60:
#             self.state = "哥么，还行，可以干饭了"
#         elif 0 <= self.time <= 30:
#             self.state = "哥么，急着去投胎么，生的"
#
#     def add_condition(self, condition_list):
#         self.condition.extend(condition_list)  # 使用 extend 来合并列表
#
#
# a = SweetPotato()
# a.cook(40)
# conditions = ["酱油", "辣椒", "醋"]
# a.add_condition(conditions)
# print(a)  # 注意这里使用 print 而不是直接调用 __str__

# class Home():
#     def __init__(self,address,area):
#         self.address = address
#         self.area = area
#         self.free_area = area
#         self.furniture =[]
#
#     def __str__(self):
#         return f'房子坐落于{self.address},占地面积{self.area},剩余面积{self.free_area},家具有{self.furniture}'
#
#     def add_furniture(self,item):
#         if self.free_area>=item.area:
#             self.furniture.append((item.name))
#             self.free_area -=item.area
#         else:
#             print('家具太大，剩余面积不足，无法容纳')
#
# class Furniture():
#     def __init__(self):
#         self.name = '床'
#         self.area = 1
#     def __str__(self):
#         return f'这个家具的名称是{self.name},占地面积为{self.area}'
#
# MyHome = Home('郑州',150)

# class Person():
#     def __init__(self,name,weight):
#         self.name = name
#
#         self.weight = weight
#     def __str__(self):
#         return f'{self.name}体重为{self.weight}公斤'
#
#     def run(self,n):
#         for i in range(n):
#             if self.weight>=40.5:
#                 self.weight-=0.5
#                 print(f'{self.name}刚才跑了100000m,减了0.5公斤，现在体重为{self.weight}公斤')
#             else :
#                 print('太瘦了，减不了')
#                 break
#
#
#     def eat(self,n):
#         for i in range(n):
#             if self.weight<=100:
#                 self.weight+=1
#                 print(f'{self.name}吃了很多，涨了1公斤，现在体重为{self.weight}公斤')
#
#             else:
#                 print('太胖了，吃不下了')
#                 break
#
# xiaoming = Person('小明',75)
# xiaomei = Person('小美',45)
#
# print(xiaoming)



class triangle():
    def __init__(self,a,b,c):
        if not(a+b>c and a+c>b and b+c>a):
            raise  ValueError('给定的边长不能构成一个三角形')
        self.a = a
        self.b = b
        self.c = c

    def calculate_size(self):
        p = (self.a+self.b+self.c)/2
        S = (p*(p-self.a)*(p-self.b)*(p-self.c))**(1/2)
        print(f'三角形的面积是：{S}')

san = triangle(2,2,5)
san.calculate_size()

class Dog(object):
    def work(self):
        print('指哪打哪---')

class DrugDog:
    def work(self):
        print('攻击敌方---')
class Dog(object):
    tooth = 10

wangcai = Dog()
xiaogei = Dog()
Dog.tooth = 12
wangcai.tooth = 20

print(Dog.tooth)
print(wangcai.tooth)
print(xiaogei.tooth)

class Dog(object):
    __tooth = 10
    @classmethod
    def get_tooth(cls):
        return cls.__tooth

wangcai = Dog()
result = wangcai.get_tooth()
print(result)


